package com.dianxin.smartpark.web.app;

import cn.dev33.satoken.annotation.SaCheckPermission;
import com.chinatelecom.response.common.CommonResponseBody;
import com.dianxin.smartpark.dao.qo.app.SmartParkAppQO;
import com.dianxin.smartpark.service.app.SmartParkAppService;
import com.dianxin.smartpark.service.vo.app.SmartParkAppVO;
import com.dianxin.sso.client.annotation.RecordLog;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * 智慧园区APP管理
 * @Authort Ricartc
 */

@RestController
@RequestMapping("/smartpark/app")
public class SmartParkAppController {
    @Resource
    SmartParkAppService smartParkAppService;


    /**
     *  查询应用管理列表
     * @param qo
     * @return
     */
    @RequestMapping("/getAppList")
    @RecordLog(name = "查询应用管理列表")
    @SaCheckPermission("/smartpark/app/getAppList")
    public CommonResponseBody<List<SmartParkAppVO>> getAppList(@RequestBody SmartParkAppQO qo){
        return smartParkAppService.getApps(qo);
    }

    /**
     * 查询APP详情
     * @return 参数需要传入appId，org_code和tenantId
     */
    @RequestMapping("/getAppDeatil")
    @RecordLog(name = "查询APP详情")
    @SaCheckPermission("/smartpark/app/getAppDeatil")
    public CommonResponseBody<SmartParkAppVO> getAppDeatil(@RequestBody SmartParkAppVO vo){
        return smartParkAppService.getAppDeatil(vo);
    }

    /**
     * 新增APP信息
     * @param vo
     * @return
     */
    @RequestMapping("/saveApp")
    @RecordLog(name = "新增APP信息")
    @SaCheckPermission("/smartpark/app/saveApp")
    public CommonResponseBody<Boolean> saveApp(@RequestBody SmartParkAppVO vo){
        return smartParkAppService.saveApp(vo);
    }

    /**
     * 修改应用信息
     * @param vo
     * @return
     */
    @RequestMapping("/updateApp")
    @RecordLog(name = "修改应用信息")
    @SaCheckPermission("/smartpark/app/updateApp")
    public CommonResponseBody<Boolean> updateApp(@RequestBody SmartParkAppVO vo){
        return smartParkAppService.updateApp(vo);
    }

    /**
     * 删除应用信息
     * @param vo 参数需要传id,租户id,appId和orgCode
     * @return
     */
    @RequestMapping("/deleteApp")
    @RecordLog(name = "删除应用信息")
    @SaCheckPermission("/smartpark/app/deleteApp")
    public CommonResponseBody<Boolean> deleteApp(@RequestBody SmartParkAppVO vo){
        return smartParkAppService.deleteApp(vo);
    }

    /**
     *  获取最新版本号的应用信息
     * @param  vo
     * @Return
     */
    @RequestMapping("/getCurrentInfoByVersionCode")
    @RecordLog(name = "获取最新版本号的应用信息")
    @SaCheckPermission("/smartpark/app/getCurrentInfoByVersionCode")
    public CommonResponseBody<SmartParkAppVO> getCurrentInfoByVersionCode(@RequestBody SmartParkAppVO vo){
        return smartParkAppService.getCurrentInfoByVersionCode(vo);
    }

}
